<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2024/2/27 0027
 * Time: 15:27
 */

namespace app\index\model;


use think\Model;

class AuthGroup extends Model
{
    /**
     * @param int $offset
     * @param int $limit
     * @param array $where
     * @return array
     */
    public function getList($offset = 0, $limit=10, $where = [])
    {
        return $this->where($where)->limit($offset, $limit)->order('id', 'desc')->select()->toArray();
    }

    /**
     * @param array $where
     * @return $this
     */
    public function getListCount($where = [])
    {
        return $this->where($where)->count();
    }

    /**
     * @param $id
     * @return array
     */
    public function getOneById($id)
    {
        return $this->where("id", $id)->findOrEmpty()->toArray();
    }

    /**
     * @param $data
     * @return int|string
     */
    public function add($data)
    {
        return $this->insert($data);
    }

    /**
     * @param $id
     * @param $data
     * @return static
     */
    public function edit($id, $data)
    {
        return $this->where("id", $id)->update($data);
    }

    /**
     *
     * @param $id
     * @return bool
     * @throws \Exception
     */
    public function del($id)
    {
        return $this->where("id", $id)->delete();
    }
}